package cn.le.listener;

import cn.le.bean.enums.EnumKafkaTopic;
import cn.le.bean.enums.EnumMsgCode;
import cn.le.bean.vo.NettyMsg;
import cn.le.netty.cient.NettyClient;
import com.alibaba.fastjson.JSONObject;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;


/**
 * im消息监听
 */
@Component
public class ImMsgListener {

    @KafkaListener(topics = {EnumKafkaTopic.im_msg})
    public void listen(String nettyMsgJson){
        NettyMsg msg = JSONObject.parseObject(nettyMsgJson,NettyMsg.class);
        if (EnumMsgCode.point_send.getCode() == msg.getCode()){
            NettyClient.sendPoint(msg);
        }if (EnumMsgCode.group_send.getCode() == msg.getCode()){
            NettyClient.sendGroup(msg);
        }
    }
}
